<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:c="http://xmlns.jcp.org/jsf/composite"
	xmlns:p="http://primefaces.org/ui">

<ui:decorate template="/jsp/WEB/pageLayout.xhtml">

	<ui:define name="centro">
		<h:form id="form">
			<p:growl id="msgs" showDetail="true" />

			<p:panel id="tpConsulta" header="Localizar POS" toggleable="true"
				toggleSpeed="500" collapsed="true" widgetVar="panel"
				style="margin-bottom:20px">
				<h:panelGrid id="gridCli" columns="5" style="border:0px">
					<h:outputLabel value="Nº série* : " />
					<p:inputText id="Serie" value="#{CadPOSBean.textoConsulta}" />


					<p:commandButton id="searchButton" image="ui-icon-search"
						update="@all" ajax="false" title="Consultar POS"
						actionListener="#{CadPOSBean.validaBusca}" />
				</h:panelGrid>
			</p:panel>

			<p:panel id="Cadastrar" header="Cadastrar POS">

				<br />

				<h:panelGrid id="cadPOS" columns="2" value="#{CadPOSBean.pos}"
					var="pos" rowIndexVar="rowIndex">

					<h:outputLabel value="Nº série* : " />
					<p:inputText id="nome" label="Nome" immediate="true"
						requiredMessage="Preencha o campo Serie"
						value="#{CadPOSBean.pos.serie}" />

					<h:outputLabel for="modelo" value="Modelo : " />
					<p:inputText id="modelo" label="Modelo"
						value="#{CadPOSBean.pos.modelo}" />

					<h:outputLabel for="ident" value="Identificador : " />
					<p:inputText id="ident" value="#{CadPOSBean.pos.identification}" />

					<h:outputLabel value="Tipo de POS : " />
					<p:selectOneMenu value="#{CadPOSBean.pos.finalidade}">
						<f:selectItem itemLabel="Receptor" itemValue="true" />
						<f:selectItem itemLabel="Emissor" itemValue="false" />
					</p:selectOneMenu>

					<h:outputText value="Setor* : " />

						<p:selectOneMenu id="setor" effect="fade"
							value="#{CadPOSBean.pos.idSetor}" style="width:173px">
							<f:selectItem itemLabel="Setores" itemValue="" />
							<f:selectItems value="#{CadPOSBean.lstSetor()}" var="setores"
								itemLabel="#{setores.descrSetor}" itemValue="#{setores.idSetor}" />
						</p:selectOneMenu>

				</h:panelGrid>
				<p:separator />

				<p:commandButton id="salvar" value="Salvar" update="@form"
					ajax="false" icon="ui-icon-plusthick"
					action="#{CadPOSBean.salvarPOS}" />

				<p:commandButton id="atualizar" value="Atualizar" update="@all"
					icon="ui-icon-disk" ajax="false"
					actionListener="#{CadPOSBean.updatePOS}" />


				<p:commandButton id="excluir" value="Excluir"
					onclick="confirmaExclusao.show()" icon="ui-icon-minus" />


			</p:panel>


			<p:panel id="Listas" header="Listagem de POS">
				<p:dataTable id="listaPos" var="poss" value="#{CadPOSBean.listaPos}"
					emptyMessage="Nenhum pos encontrado!"
					style="margin-top:20px; position: auto" paginator="true"
					selectionMode="single" selection="#{CadPOSBean.poss}"
					rowKey="#{poss.serie}">
					<p:ajax event="rowSelect" update=":form:cadPOS"
						listener="#{CadPOSBean.show()}" />

					<p:column style="width: 50px;" sortBy="serie">
						<f:facet name="header">Série</f:facet>
						<h:outputText value="#{poss.serie}" />
					</p:column>

					<p:column style="width: 50px;" sortBy="identification">
						<f:facet name="header">Identificador</f:facet>
						<h:outputText value="#{poss.identification}" />
					</p:column>

					<p:column style="width: 50px;" sortBy="Modelo">
						<f:facet name="header">Modelo</f:facet>
						<h:outputText value="#{poss.modelo}" />
					</p:column>


					<p:column style="width: 50px;" sortBy="finalidade">
						<f:facet name="header">Finalidade</f:facet>
						<h:outputText value="Receptor" rendered="#{poss.finalidade}" />
						<h:outputText value="Emissor" rendered="#{not poss.finalidade}" />
					</p:column>

					<p:column style="width: 50px;" sortBy="setor">
						<f:facet name="header">Setor</f:facet>
						<h:outputText value="#{poss.descrSetor}" />
					</p:column>

				</p:dataTable>
			</p:panel>
		</h:form>

		<p:confirmDialog id="confirmaExclusao"
			message="Confirma exclusão deste POS ?" header="Confirmação"
			severity="alert" widgetVar="confirmaExclusao" modal="true"
			appendTo="@(body)">
			<h:form>
				<p:commandButton id="confirmaBtn" value="Sim"
					onclick="confirmaExclusao.hide()" action="#{CadPOSBean.deletarPOS}"
					ajax="false" icon="ui-icon-check">
				</p:commandButton>
				<p:commandButton id="recusaBtn" value="Não"
					onclick="confirmaExclusao.hide()" icon="ui-icon-close" />
			</h:form>
		</p:confirmDialog>

	</ui:define>
</ui:decorate>
</html>
